**************************************************************
*HURRICANES AND GAS GOUGING - APPENDIX SUMMARY STATISTICS
**************************************************************

********************************************************
*FIGURE B.1 - ANNUAL PRICE FIGURES
********************************************************
****
*2004
preserve
keep if year==2004 & sample_main==1 
gen ret_fl=retail if state_code=="FL"
gen ret_la=retail if state_code=="LA"
gen whole_fl=wholesale if state_code=="FL"
gen whole_la=wholesale if state_code=="LA"

*Bonnie/Charlie
gen bc=1 if storm_name=="BONCHAR"
	sort station_id bc
	bys station_id: carryforward bc, replace
	replace bc=0 if missing(bc)
gen ret_bc=retail if bc==1 
gen whole_bc=wholesale if bc==1 

*Frances
gen fr=1 if storm_name=="FRANCES" 
	sort station_id fr
	bys station_id: carryforward fr, replace
	replace fr=0 if missing(fr)
gen ret_fr=retail if fr==1 
gen whole_fr=wholesale if fr==1

*Ivan
gen iv=1 if storm_name=="IVAN" 
	sort station_id iv
	bys station_id: carryforward iv, replace
	replace iv=0 if missing(iv)
gen ret_iv=retail if iv==1
gen whole_iv=wholesale if iv==1 	

*Jeanne
gen je=1 if storm_name=="JEANNE" 
	sort station_id je
	bys station_id: carryforward je, replace
	replace je=0 if missing(je)
gen ret_je=retail if je==1
gen whole_je=wholesale if je==1 

gen ret_coast_fl=retail if coast_pfz==1 & state_code=="FL"		
gen whole_coast_fl=wholesale if coast_pfz==1 & state_code=="FL"	
gen ret_coast_la=retail if coast_pfz==1 & state_code=="LA"		
gen whole_coast_la=wholesale if coast_pfz==1 & state_code=="LA"	

collapse (mean) retail wholesale bulk ret_fl ret_la whole_fl whole_la ret_bc ///
				whole_bc ret_fr whole_fr ret_iv whole_iv ret_je whole_je ///
				ret_coast_fl whole_coast_fl ret_coast_la whole_coast_la, by(date)

*Average Prices
twoway (scatteri 2.5 `=td(12aug2004)'  2.5 `=td(13aug2004)',  bcolor(gs15) recast(area))  ///
	   (scatteri 2.5 `=td(06sep2004)'  2.5 `=td(07sep2004)', bcolor(gs15) recast(area)) ///
	   (scatteri 2.5 `=td(16sep2004)'  2.5 `=td(17sep2004)', bcolor(gs15) recast(area))  ///
	   (scatteri 2.5 `=td(26sep2004)' 2.5 `=td(27sep2004)', bcolor(gs15) recast(area))  ///
	   (line ret_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_coast_la date, lc(edkblue*0.7) lw(.1)) ///	   
	   (line ret_bc date, lc(edkblue*0.7)  lw(.1)) ///	   
	   (line ret_fr date, lc(edkblue*0.7)  lw(.1)) ///	   
	   (line ret_iv date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_je date, lc(edkblue*0.7) lw(.1)) ///	   
	   (line ret_fl date, lc(edkblue*0.7) lw(.1))	  ///
	   (line ret_la date, lc(edkblue*0.7) lw(.1))	  ///
	   (line retail date, lc(edkblue) lw(0.7))	  ///
	   (line whole_coast_fl date, lc(cranberry*0.7) lw(.1)) ///	 
	   (line whole_coast_la date, lc(cranberry*0.7) lw(.1)) ///	   	   
	   (line whole_bc date, lc(cranberry*0.7) lw(.1)) ///	   
	   (line whole_fr date, lc(cranberry*0.7) lw(.1)) ///	   
	   (line whole_iv date, lc(cranberry*0.7) lw(.1)) ///	 
	   (line whole_iv date, lc(cranberry*0.7) lw(.1)) ///	   	   
	   (line whole_je date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_la date, lc(cranberry*0.7) lw(.1)) ///
	   (line whole_fl date, lc(cranberry*0.7) lw(.1)) ///
	   (line wholesale date,  lc(cranberry) lw(0.7)) ///
	   (line bulk date,  lc(black) lw(0.5)), ///
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(16223(30)16375,format(%td)  labsize(vsmall)) ///
	  ylabel(1(0.5)2.5, nogrid angle(horizontal) labsize(vsmall) format(%9.2f)) ///
	  legend(order(13 "Retail" 23 "Wholesale" 24 "Bulk") size(vsmall) ///
	    region(lcolor(white)) cols(2) ring(0) position(11)) ///
	  xtitle("",size(small))  ytitle("2004 Prices ($/gal)", size(vsmall)) ///
	  text(2.4 `=td(12aug2004)' "Bonnie/Charlie" "(FL)", place(e) size(vsmall)) ///
	  text(2.4 `=td(06sep2004)' "Frances" "(FL)", place(e) size(vsmall)) ///
	  text(2.4 `=td(16sep2004)' "Ivan" "(FL/LA)", place(e) size(vsmall)) ///
	  text(2.4 `=td(26sep2004)' "Jeanne" "(FL)", place(e) size(vsmall)) ///
	  fysize(50) name(graph1, replace)
graph export $figs/prices_2004_$outputdate.png, replace width(4000)
restore 

****
*2005
preserve
keep if year==2005 & sample_main==1 
gen ret_fl=retail if state_code=="FL"
gen ret_la=retail if state_code=="LA"
gen whole_fl=wholesale if state_code=="FL"
gen whole_la=wholesale if state_code=="LA"

*Arlene
gen ar=1 if storm_name=="ARLENE"
	sort station_id ar
	bys station_id: carryforward ar, replace
	replace ar=0 if missing(ar)
gen ret_ar=retail if ar==1 
gen whole_ar=wholesale if ar==1 

*DENNIS
gen de=1 if storm_name=="DENNIS"
	sort station_id de
	bys station_id: carryforward de, replace
	replace de=0 if missing(de)
gen ret_de=retail if de==1
gen whole_de=wholesale if de==1

*KATRINA
gen ka=1 if storm_name=="KATRINA"
	sort station_id ka
	bys station_id: carryforward ka, replace
	replace ka=0 if missing(ka)
gen ret_ka_fl=retail if ka==1 & state_code=="FL"		
gen whole_ka_fl=wholesale if ka==1 & state_code=="FL"		
gen ret_ka_la=retail if ka==1 & state_code=="LA"	
gen whole_ka_la=wholesale if ka==1 & state_code=="LA"	

*RITA
gen ri=1 if storm_name=="RITA"
	sort station_id ri
	bys station_id: carryforward ri, replace
	replace ri=0 if missing(ri)
gen ret_ri_fl=retail if ri==1 & state_code=="FL"	
gen whole_ri_fl=wholesale if ri==1 & state_code=="FL"	
gen ret_ri_la=retail if ri==1 & state_code=="LA"	
gen whole_ri_la=wholesale if ri==1 & state_code=="LA"	

*WILMA
gen wi=1 if storm_name=="WILMA"
	sort station_id wi
	bys station_id: carryforward wi, replace
	replace wi=0 if missing(wi)
gen ret_wi=retail if ri==1 
gen whole_wi=wholesale  if wi==1 

gen ret_coast_fl=retail if coast_pfz==1 & state_code=="FL"		
gen whole_coast_fl=wholesale if coast_pfz==1 & state_code=="FL"	
gen ret_coast_la=retail if coast_pfz==1 & state_code=="LA"		
gen whole_coast_la=wholesale if coast_pfz==1 & state_code=="LA"	

collapse (mean) ret_fl ret_la whole_fl whole_la ret_ar whole_ar ret_de ///
                whole_de ret_ka_fl whole_ka_fl ret_ka_la whole_ka_la ///
				ret_ri_fl whole_ri_fl ret_ri_la whole_ri_la ret_wi ///
				whole_wi ret_coast_fl whole_coast_fl ret_coast_la ///
				whole_coast_la retail wholesale bulk, by(date)
		
*Average Prices 
twoway(scatteri 3.5 `=td(11jun2005)' 3.5 `=td(12jun2005)', bcolor(gs15) recast(area)) ///
      (scatteri 3.5 `=td(10jul2005)' 3.5 `=td(11jul2005)', bcolor(gs15) recast(area)) ///
	  (scatteri 3.5 `=td(25aug2005)' 3.5 `=td(26aug2005)' 3.5 `=td(27aug2005)' 3.5 `=td(28aug2005)' 3.5 `=td(29aug2005)', bcolor(gs15) recast(area)) ///
	  (scatteri 3.5 `=td(24sep2005)' 3.5 `=td(25sep2005)', bcolor(gs15) recast(area)) ///
	  (scatteri 3.5 `=td(24oct2005)' 3.5 `=td(25oct2005)', bcolor(gs15) recast(area)) ///
	   (line ret_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_ar date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_de date, lc(edkblue*0.7) lw(.1)) ///	   
	   (line ret_ka_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_ka_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_ri_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_ri_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_wi date, lc(edkblue*0.7) lw(.1)) ///	
	   (line retail date,  lc(edkblue) lw(0.7)) ///
	   (line whole_coast_fl date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_coast_la date, lc(cranberry*0.7) lw(.1)) ///	 	   
	   (line whole_ar date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_de date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_ka_fl date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_ka_la date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_ri_fl date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_ri_la date, lc(cranberry*0.7) lw(.1)) ///	 
	   (line whole_wi date, lc(cranberry*0.7) lw(.1)) ///	
	   (line wholesale date,  lc(cranberry) lw(0.7)) ///
	   (line bulk date,  lc(black) lw(0.5)), ///
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(16588(30)16740, format(%td)  labsize(vsmall)) ///
	   ylabel(1(0.5)3.5, nogrid angle(horizontal) labsize(vsmall) format(%9.2f)) ///
	   legend(off) ///
	   xtitle("",size(small))  ytitle("2005 Prices ($/gal)", size(vsmall)) ///
	   text(3.4 `=td(11jun2005)' "Arlene" "(FL)", place(e) size(vsmall)) ///
	   text(3.4 `=td(10jul2005)' "Dennis" "(FL)", place(e) size(vsmall)) ///
	   text(3.4 `=td(25aug2005)' "Katrina" "(FL/LA)", place(e) size(vsmall)) ///
	   text(3.4 `=td(24sep2005)' "Rita" "(FL/LA)", place(e) size(vsmall)) ///
	   text(3.4 `=td(24oct2005)' "Wilma" "(FL)", place(e) size(vsmall)) ///
	   fysize(50) name(graph2, replace)
graph export $figs/prices_2005.png, replace width(4000)
restore


****
*2006
preserve
keep if year==2006 & sample_main==1 

gen ret_fl=retail if state_code=="FL"
gen ret_la=retail if state_code=="LA"
gen whole_fl=wholesale if state_code=="FL"
gen whole_la=wholesale if state_code=="LA"

*Alberto
gen al=1 if storm_name=="ALBERTO"
	sort station_id al
	bys station_id: carryforward al, replace
	replace al=0 if missing(al)
gen ret_al=retail if al==1	
gen whole_al=wholesale if al==1	

gen ret_coast_fl=retail if coast_pfz==1 & state_code=="FL"		
gen whole_coast_fl=wholesale if coast_pfz==1 & state_code=="FL"	
gen ret_coast_la=retail if coast_pfz==1 & state_code=="LA"		
gen whole_coast_la=wholesale if coast_pfz==1 & state_code=="LA"	

collapse (mean) ret_fl ret_la whole_fl whole_la ret_al whole_al ///
                ret_coast_fl whole_coast_fl ret_coast_la whole_coast_la ///
				retail wholesale bulk, by(date)
		
*Average Prices
twoway(scatteri 3.5 `=td(13jun2006)'  3.5 `=td(14jun2006)', bcolor(gs15) recast(area)) ///
	   (line ret_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_al date, lc(edkblue*0.7) lw(.1)) ///	
	   (line retail date,lc(edkblue) lw(0.7))	  ///
	   (line whole_coast_fl date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_coast_la date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_al date, lc(cranberry*0.7) lw(.1)) ///	 
	   (line wholesale date,   lc(cranberry) lw(0.7)) ///
	   (line bulk date,  lc(black) lw(0.5)), ///	   
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(16953(30)17105, format(%td)  labsize(vsmall)) ///
	   ylabel(1(0.5)3.5, nogrid angle(horizontal) labsize(vsmall) format(%9.2f)) ///
	   legend(off) ///
	   xtitle("",size(small))  ytitle("2006 Prices ($/gal)", size(vsmall)) ///
	   text(3.4 `=td(13jun2006)' "Alberto" "(FL)", place(e) size(vsmall)) ///
	   fysize(50) name(graph3, replace)
graph export $figs/prices_2006.png, replace width(4000)
restore


****
*2007
preserve
keep if year==2007 & sample_main==1 

gen ret_fl=retail if state_code=="FL"
gen ret_la=retail if state_code=="LA"
gen whole_fl=wholesale if state_code=="FL"
gen whole_la=wholesale if state_code=="LA"

*HUMBERTO
gen hu=1 if storm_name=="HUMBERTO"
	sort station_id hu
	bys station_id: carryforward hu, replace
	replace hu=0 if missing(hu)
gen ret_hu_la=retail if hu==1	
gen whole_hu_la=wholesale if hu==1	

gen ret_coast_fl=retail if coast_pfz==1 & state_code=="FL"		
gen whole_coast_fl=wholesale if coast_pfz==1 & state_code=="FL"	
gen ret_coast_la=retail if coast_pfz==1 & state_code=="LA"		
gen whole_coast_la=wholesale if coast_pfz==1 & state_code=="LA"	

collapse (mean) ret_fl ret_la whole_fl whole_la ret_hu_la whole_hu_la ///
                ret_coast_fl whole_coast_fl ret_coast_la whole_coast_la ///
				retail wholesale bulk, by(date)
		
*Average Prices
twoway(scatteri 3.5 `=td(13sep2007)' 3.5 `=td(14sep2007)', bcolor(gs15) recast(area)) ///
	   (line ret_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_hu_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line retail date,   lc(edkblue) lw(0.7))	  ///
	   (line whole_coast_fl date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_coast_la date,lc(cranberry*0.7) lw(.1)) ///	   	   
	   (line whole_hu_la date,lc(cranberry*0.7) lw(.1)) ///	   
	   (line wholesale date,   lc(cranberry) lw(0.7)) ///
	   (line bulk date,  lc(black) lw(0.5)), ///
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(17318(30)17470, format(%td)  labsize(vsmall)) ///
	   ylabel(1(0.5)3.5, nogrid angle(horizontal) labsize(vsmall) format(%9.2f)) ///
	   legend(off) ///
	   xtitle("",size(small))  ytitle("2007 Prices ($/gal)", size(vsmall)) ///
	   text(3.4 `=td(13sep2007)' "Humberto" "(LA)", place(e) size(vsmall)) ///
	   fysize(50) name(graph4, replace)
graph export $figs/prices_2007.png, replace width(4000)
restore

****
*2008
preserve
keep if year==2008 & sample_main==1 

gen ret_fl=retail if state_code=="FL"
gen ret_la=retail if state_code=="LA"
gen whole_fl=wholesale if state_code=="FL"
gen whole_la=wholesale if state_code=="LA"

*GUSTAV
gen gu=1 if storm_name=="GUSTAV"
	sort station_id gu
	bys station_id: carryforward gu, replace
	replace gu=0 if missing(gu)
gen ret_gu_la=retail if gu==1	
gen whole_gu_la=wholesale if gu==1	

*IKE
gen ik=1 if storm_name=="IKE"
	sort station_id ik
	bys station_id: carryforward ik, replace
	replace ik=0 if missing(ik)
gen ret_ik_la=retail if gu==1	
gen whole_ik_la=wholesale if ik==1	

gen ret_coast_fl=retail if coast_pfz==1 & state_code=="FL"		
gen whole_coast_fl=wholesale if coast_pfz==1 & state_code=="FL"	
gen ret_coast_la=retail if coast_pfz==1 & state_code=="LA"		
gen whole_coast_la=wholesale if coast_pfz==1 & state_code=="LA"	

collapse (mean) ret_fl ret_la whole_fl whole_la ///
                ret_gu_la whole_gu_la ret_ik_la whole_ik_la ///
                ret_coast_fl whole_coast_fl ret_coast_la whole_coast_la ///
				retail wholesale bulk, by(date)
		
*Average Prices
twoway(scatteri 5 `=td(01sep2008)' 5 `=td(02sep2008)', bcolor(gs15) recast(area)) ///
	  (scatteri 5 `=td(13sep2008)' 5 `=td(14sep2008)', bcolor(gs15) recast(area)) ///
	   (line ret_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_gu_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line ret_ik_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line retail date, lc(edkblue) lw(0.7))	  ///
	   (line whole_coast_fl date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_coast_la date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_gu_la date, lc(cranberry*0.7) lw(.1)) ///	
	   (line whole_ik_la date, lc(cranberry*0.7) lw(.1)) ///	
	   (line wholesale date,   lc(cranberry) lw(0.7)) ///
	   (line bulk date,  lc(black) lw(0.5)), ///
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(17684(30)17836, format(%td)  labsize(vsmall)) ///
	   ylabel(1(1)5, nogrid angle(horizontal) labsize(vsmall) format(%9.2f)) ///
	   legend(off) ///
	   xtitle("",size(small))  ytitle("2008 Prices ($/gal)", size(vsmall)) ///
	   text(4.9 `=td(01sep2008)' "Gustav" "(LA)", place(e) size(vsmall)) ///
	   text(4.9 `=td(14sep2008)' "Ike" "(FL)", place(e) size(vsmall)) ///
	   fysize(50) name(graph5, replace)
graph export $figs/prices_2008.png, replace width(4000)
restore

graph combine graph1 graph2, cols(1)  iscale(1) /// 
              graphregion(color(white))  imargin(0 0 0 0) 	
graph export $figs\prices_0405.png, width(4000) replace

graph combine graph3 graph4, cols(1)  iscale(1) /// 
              graphregion(color(white))  imargin(0 0 0 0) 	
graph export $figs\prices_0607.png, width(4000) replace



********************************************************
*FIGURE B.2 - Average precipitation
********************************************************

****
*2004
preserve
keep if year==2004 & sample_main==1 

*Reported in 1/10 milimeters, so convert to inches
replace prcp_near1=prcp_near1/10/25.4
gen prcp_fl=prcp_near1 if state_code=="FL"
gen prcp_la=prcp_near1 if state_code=="LA"

*Bonnie/Charlie
gen bc=1 if storm_name=="BONCHAR"
	sort station_id bc
	bys station_id: carryforward bc, replace
	replace bc=0 if missing(bc)
gen prcp_bc=prcp_near1 if bc==1 

*Frances
gen fr=1 if storm_name=="FRANCES" 
	sort station_id fr
	bys station_id: carryforward fr, replace
	replace fr=0 if missing(fr)
gen prcp_fr=prcp_near1 if fr==1 

*Ivan
gen iv=1 if storm_name=="IVAN" 
	sort station_id iv
	bys station_id: carryforward iv, replace
	replace iv=0 if missing(iv)
gen prcp_iv=prcp_near1 if iv==1

*Jeanne
gen je=1 if storm_name=="JEANNE" 
	sort station_id je
	bys station_id: carryforward je, replace
	replace je=0 if missing(je)
gen prcp_je=prcp_near1 if je==1

gen prcp_coast_fl=prcp_near1 if coast_pfz==1 & state_code=="FL"		
gen prcp_coast_la=prcp_near1 if coast_pfz==1 & state_code=="LA"		

collapse (mean) prcp_near1 prcp_fl prcp_la prcp_bc prcp_fr prcp_iv prcp_je ///
				prcp_coast_fl prcp_coast_la, by(date)
		
*Average precipitation
twoway (scatteri 5 `=td(12aug2004)' 5 `=td(13aug2004)', bcolor(gs15) recast(area))  ///
	   (scatteri 5 `=td(06sep2004)' 5 `=td(07sep2004)', bcolor(gs15) recast(area)) ///
	   (scatteri 5 `=td(16sep2004)' 5 `=td(17sep2004)', bcolor(gs15) recast(area))  ///
	   (scatteri 5 `=td(26sep2004)' 5 `=td(27sep2004)', bcolor(gs15) recast(area))  ///
	   (line prcp_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_bc date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_fr date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_iv date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_je date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_near1 date, lc(edkblue) lw(0.7)), ///
	   graphregion(color(white)) bgcolor(white)   ///
	   xlabel(16223(30)16375,format(%td)  labsize(vsmall)) ///
	  ylabel(0(1)5, nogrid angle(horizontal) labsize(vsmall) format(%9.0f)) ///
	  legend(order(13 "Average Precipitation" "(FL/LA)") size(vsmall) ///
	    region(lcolor(white)) cols(1) ring(0) position(11)) ///
	  xtitle("",size(small))  ytitle("2004 Avg. Precipitation (inches/day)", size(vsmall)) ///
	  text(4.9 `=td(12aug2004)' "Bonnie/Charlie" "(FL)", place(e) size(vsmall)) ///
	  text(4.9 `=td(06sep2004)' "Frances" "(FL)", place(e) size(vsmall)) ///
	  text(4.9 `=td(16sep2004)' "Ivan" "(FL/LA)", place(e) size(vsmall)) ///
	  text(4.9 `=td(26sep2004)' "Jeanne" "(FL)", place(e) size(vsmall)) ///
	  fysize(50) name(graph1, replace)
graph export $figs/precip_2004.png, replace width(4000)
restore


****
*2005
preserve
keep if year==2005 & sample_main==1 

*Reported in 1/10 milimeters, so convert to inches
replace prcp_near1=prcp_near1/10/25.4
gen prcp_fl=prcp_near1 if state_code=="FL"
gen prcp_la=prcp_near1 if state_code=="LA"

*Arlene
gen ar=1 if storm_name=="ARLENE"
	sort station_id ar
	bys station_id: carryforward ar, replace
	replace ar=0 if missing(ar)
gen prcp_ar=prcp_near1 if ar==1 
 
*DENNIS
gen de=1 if storm_name=="DENNIS"
	sort station_id de
	bys station_id: carryforward de, replace
	replace de=0 if missing(de)
gen prcp_de=prcp_near1 if de==1
 
*KATRINA
gen ka=1 if storm_name=="KATRINA"
	sort station_id ka
	bys station_id: carryforward ka, replace
	replace ka=0 if missing(ka)
gen prcp_ka_fl=prcp_near1 if ka==1 & state_code=="FL"		
gen prcp_ka_la=prcp_near1 if ka==1 & state_code=="LA"	
 
*RITA
gen ri=1 if storm_name=="RITA"
	sort station_id ri
	bys station_id: carryforward ri, replace
	replace ri=0 if missing(ri)
gen prcp_ri_fl=prcp_near1 if ri==1 & state_code=="FL"	
gen prcp_ri_la=prcp_near1 if ri==1 & state_code=="LA"	
 
*WILMA
gen wi=1 if storm_name=="WILMA"
	sort station_id wi
	bys station_id: carryforward wi, replace
	replace wi=0 if missing(wi)
gen prcp_wi=prcp_near1 if ri==1 
gen prcp_coast_fl=prcp_near1 if coast_pfz==1 & state_code=="FL"		
gen prcp_coast_la=prcp_near1 if coast_pfz==1 & state_code=="LA"		
 
collapse (mean) prcp_near1 prcp_fl prcp_la prcp_ar prcp_de prcp_ka_fl ///
                prcp_ka_la prcp_ri_fl prcp_ri_la prcp_wi prcp_coast_fl ///
				prcp_coast_la, by(date)
		
*Average precipitation
twoway (scatteri 6 `=td(11jun2005)' 6 `=td(12jun2005)', bcolor(gs15) recast(area)) ///
      (scatteri 6 `=td(10jul2005)' 6 `=td(11jul2005)', bcolor(gs15) recast(area)) ///
	  (scatteri 6 `=td(25aug2005)' 6 `=td(26aug2005)' 6 `=td(27aug2005)' 6 `=td(28aug2005)' 6 `=td(29aug2005)', bcolor(gs15) recast(area)) ///
	  (scatteri 6 `=td(24sep2005)' 6 `=td(25sep2005)', bcolor(gs15) recast(area)) ///
	  (scatteri 6 `=td(24oct2005)' 6 `=td(25oct2005)', bcolor(gs15) recast(area)) ///
	   (line prcp_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_ar date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_de date,  lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_ka_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_ka_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_ri_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_ri_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_wi date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_near1 date, lc(edkblue) lw(0.7)), ///
	   graphregion(color(white)) bgcolor(white)   ///
	   xlabel(16588(30)16740, format(%td)  labsize(vsmall)) ///
	  ylabel(0(1)6, nogrid angle(horizontal) labsize(vsmall) format(%9.0f)) ///
	  legend(off) ///
	  xtitle("",size(small))  ytitle("2005 Avg. Precipitation (inches/day)", size(vsmall)) ///
	   text(5.9 `=td(11jun2005)' "Arlene" "(FL)", place(e) size(vsmall)) ///
	   text(5.9 `=td(10jul2005)' "Dennis" "(FL/LA)", place(e) size(vsmall)) ///
	   text(5.9 `=td(25aug2005)' "Katrina" "(FL/LA)", place(e) size(vsmall)) ///
	   text(5.9 `=td(24sep2005)' "Rita" "(FL/LA)", place(e) size(vsmall)) ///
	   text(5.9 `=td(24oct2005)' "Wilma" "(FL)", place(e) size(vsmall)) ///
	   fysize(50) name(graph2, replace)
graph export $figs/precip_2005.png, replace width(4000)	
restore


****
*2006
preserve
keep if year==2006 & sample_main==1 

*Reported in 1/10 milimeters, so convert to inches
replace prcp_near1=prcp_near1/10/25.4

gen prcp_fl=prcp_near1 if state_code=="FL"
gen prcp_la=prcp_near1 if state_code=="LA"

*Alberto
gen al=1 if storm_name=="ALBERTO"
	sort station_id al
	bys station_id: carryforward al, replace
	replace al=0 if missing(al)
gen prcp_al=prcp_near1 if al==1	
 
gen prcp_coast_fl=prcp_near1 if coast_pfz==1 & state_code=="FL"		
gen prcp_coast_la=prcp_near1 if coast_pfz==1 & state_code=="LA"		
 
collapse (mean) prcp_fl prcp_la prcp_al prcp_coast_fl prcp_coast_la prcp_near1, by(date)
		
*Average precipitation
twoway(scatteri 4 `=td(13jun2006)' 4 `=td(14jun2006)', bcolor(gs15) recast(area)) ///
	   (line prcp_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_al date,  lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_near1 date, lc(edkblue) lw(0.7)), ///
	   graphregion(color(white)) bgcolor(white)   ///
	   xlabel(16953(30)17105, format(%td)  labsize(vsmall)) ///
	  ylabel(0(1)4, nogrid angle(horizontal) labsize(vsmall) format(%9.0f)) ///
	  legend(off) ///
	  xtitle("",size(small))  ytitle("2006 Avg. Precipitation (inches/day)", size(vsmall)) ///
	   text(3.9 `=td(13jun2006)' "Alberto" "(FL)", place(e) size(vsmall)) ///
	   fysize(50) name(graph3, replace)
graph export $figs/precip_2006.png, replace width(4000)	
restore


****
*2007
preserve
keep if year==2007 & sample_main==1 

*Reported in 1/10 milimeters, so convert to inches
replace prcp_near1=prcp_near1/10/25.4

gen prcp_fl=prcp_near1 if state_code=="FL"
gen prcp_la=prcp_near1 if state_code=="LA"
  
*HUMBERTO
gen hu=1 if storm_name=="HUMBERTO"
	sort station_id hu
	bys station_id: carryforward hu, replace
	replace hu=0 if missing(hu)
gen prcp_hu_la=prcp_near1 if hu==1	
 
gen prcp_coast_fl=prcp_near1 if coast_pfz==1 & state_code=="FL"		
gen prcp_coast_la=prcp_near1 if coast_pfz==1 & state_code=="LA"		
 
collapse (mean) prcp_near1 prcp_fl prcp_la prcp_hu_la prcp_coast_fl ///
                prcp_coast_la, by(date)
		
*Average precipitation
twoway(scatteri 4 `=td(13sep2007)' 4 `=td(14sep2007)', bcolor(gs15) recast(area)) ///
	   (line prcp_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_hu_la date, lc(edkblue*0.7) lw(.1)) ///	 
	   (line prcp_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_near1 date, lc(edkblue) lw(0.7)), ///
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(17318(30)17470, format(%td)  labsize(vsmall)) ///
	  ylabel(0(1)4, nogrid angle(horizontal) labsize(vsmall) format(%9.0f)) ///
	  legend(off) ///
	  xtitle("",size(small))  ytitle("2007 Avg. Precipitation (inches/day)", size(vsmall)) ///
	   text(3.9 `=td(13sep2007)' "Humberto" "(LA)", place(e) size(vsmall)) ///
	   fysize(50) name(graph4, replace)
graph export $figs/precip_2007.png, replace width(4000)	
restore

****
*2008
preserve
keep if year==2008 & sample_main==1 

*Reported in 1/10 milimeters, so convert to inches
replace prcp_near1=prcp_near1/10/25.4
gen prcp_fl=prcp_near1 if state_code=="FL"
gen prcp_la=prcp_near1 if state_code=="LA"
 
*GUSTAV
gen gu=1 if storm_name=="GUSTAV"
	sort station_id gu
	bys station_id: carryforward gu, replace
	replace gu=0 if missing(gu)
gen prcp_gu_la=prcp_near1 if gu==1	
 
*IKE
gen ik=1 if storm_name=="IKE"
	sort station_id ik
	bys station_id: carryforward ik, replace
	replace ik=0 if missing(ik)
gen prcp_ik_la=prcp_near1 if gu==1	
 
gen prcp_coast_fl=prcp_near1 if coast_pfz==1 & state_code=="FL"		
gen prcp_coast_la=prcp_near1 if coast_pfz==1 & state_code=="LA"		
 
collapse (mean) prcp_fl prcp_la prcp_gu_la prcp_ik_la prcp_coast_fl ///
                prcp_coast_la prcp_near1, by(date)
		
*Average precipitation
twoway(scatteri 5 `=td(01sep2008)' 5 `=td(02sep2008)', bcolor(gs15) recast(area)) ///
	  (scatteri 5 `=td(13sep2008)' 5 `=td(14sep2008)', bcolor(gs15) recast(area)) ///
	   (line prcp_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_la date, lc(edkblue*0.7) lw(.1)) ///	  
	   (line prcp_gu_la date, lc(edkblue*0.7) lw(.1)) ///	 
	   (line prcp_ik_la date, lc(edkblue*0.7) lw(.1)) ///	 
	   (line prcp_coast_fl date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_coast_la date, lc(edkblue*0.7) lw(.1)) ///	
	   (line prcp_near1 date, lc(edkblue) lw(0.7)), ///
	   graphregion(color(white)) bgcolor(white) ///
	   xlabel(17684(30)17836, format(%td)  labsize(vsmall)) ///
	  ylabel(0(1)5, nogrid angle(horizontal) labsize(vsmall) format(%9.0f)) ///
	  legend(off) ///
	  xtitle("",size(small))  ytitle("2008 Avg. Precipitation (inches/day)", size(vsmall)) ///
	   text(4.9 `=td(01sep2008)' "Gustav" "(FL)", place(e) size(vsmall)) ///
	   text(4.9 `=td(13sep2008)' "Ike" "(FL)", place(e) size(vsmall)) ///
	   fysize(50) name(graph5, replace)
graph export $figs/precip_2008.png, replace width(4000)	
restore

graph combine graph1 graph2, cols(1)  iscale(1) /// 
              graphregion(color(white))  imargin(0 0 0 0) 	
graph export $figs\precip_0405.png, width(4000) replace

graph combine graph3 graph4, cols(1)  iscale(1) /// 
              graphregion(color(white))  imargin(0 0 0 0) 	
graph export $figs\precip_0607.png, width(4000) replace